﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using POSSystem.BLL;
namespace WebUI.Controls
{
    public partial class EditUserCtrl : BaseEditControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            base.Page_Load(sender, e);

            if (!IsPostBack)
            {
                POSSystem.BLL.Roles group = POSSystem.BLL.Roles.GetAllActiveRoles();
                Utilities.LoadDropDownList(ddlRoles, group.DefaultView, POSSystem.BLL.Roles.ColumnNames.RoleName, POSSystem.BLL.Roles.ColumnNames.ID);
            }
        }

        public string UserName
        {
            get { return txtUserName.Text; }
            set { txtUserName.Text = value; }
        }

        public string FullName
        {
            get { return txtFullName.Text; }
            set { txtFullName.Text = value; }
        }

        public string Password
        {
            get { return txtPassword.Text; }
            set { txtPassword.Attributes["value"] = value; txtRetypePassword.Attributes["value"] = value; }
        }

        public string Phone
        {
            get { return txtPhone.Text; }
            set { txtPhone.Text = value; }
        }

        public int Role
        {
            get { return ddlRoles.SelectedIndex > 0 ? int.Parse(ddlRoles.SelectedValue) : 0; }
            set { ddlRoles.SelectedValue = value.ToString(); }
        }

        public string Address
        {
            get { return txtAddress.Text; }
            set { txtAddress.Text = value; }
        }

        public string RoleName
        {
            get { return ddlRoles.SelectedItem.Text; }
        }
    }
}